package auth

import uk.ac.soton.itinnovation.grid.client.proxy.ServiceFactory;
import uk.ac.soton.itinnovation.grid.client.proxy.HelperProxyFactory;

class User {
    String email
    String password
    String userName

    String toString()
        {"$userName"}
        
    String keystoreLocation
    String subjectDN
            
    ServiceFactory serviceFactory;
    
    HelperProxyFactory helperProxyFactory; 
        
    def static transients = ['serviceFactory','helperProxyFactory']
    
    static hasMany = [roles:Role]

    // eager fetching gets around the problem of one to many relations not
    // be eagerly fetched from the db realm.
   // static fetchMode = [roles:'eager']
    
    static constraints = {
        email(email:true, unique:true, blank:false)
        password(blank:false, nullable:false)
        userName(blank:false,unique:true)
        keystoreLocation(nullable:true)
        subjectDN(nullable:true)
        roles(nullable:true)
    }

}
